import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import Categories from '../components/categories.vue'
import dierye from '../components/dierye.vue'
import upload from '../components/upload.vue'
import Comment from '../components/comment.vue'
const Cart = ()=>import("../components/Cart.vue")
const CartDetail = ()=>import("../components/CartDetail.vue")
import order from '../components/order.vue'
import user from '../components/user.vue'
import addgoods from '../components/addgoods.vue'


Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const routes = [{
  path: '/',
  name: 'Login',
  component: Login
},
{
  path: '/home',
  name: 'Home',
  component: Home,
  children: [{
    path: '/home',
    name: 'Categories',
    component: Categories
  },
      {
        path: '/home/dierye',
        name: 'dierye',
        component: dierye
      },
      {
        path: '/home/upload',
        name: 'upload',
        component: upload
      },
      {
        path:"/home/cart",
        name:"Cart",
        component:Cart
      },
      {
        path:"/home/cart/:id",
        name:"CartDetail",
        component:CartDetail
      },
      {
        path: '/home/order',
        name: 'order',
        component: order
      },
      {
        path: '/home/addgoods',
        name: 'addgoods',
        component: addgoods
      },
      {
        path: '/home/user',
        name: 'user',
        component: user
      },
      {
        path: '/home/comment',
        name: 'comment',
        component: Comment
    
      }
    ]
  },
  
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router